Partial Class RIAssessments_TemplateTwo
    Inherits System.Web.UI.UserControl

    ''' <summary>
    ''' Gets or sets the level of assistance dropdownlist's selected value.
    ''' </summary>	
    ''' <remarks></remarks>
    Public Property LevelOfAssitanceId() As Integer
        Get
            Return Me.LevelOfAssistanceDropDownList.SelectedValue
        End Get
        Set(ByVal value As Integer)
            Me.LevelOfAssistanceDropDownList.SelectedValue = value
            If value = 0 Then
                Me.LevelOfAssistanceReadOnlyLabel.Text = ""
            Else
                Me.LevelOfAssistanceReadOnlyLabel.Text = Me.LevelOfAssistanceDropDownList.SelectedItem.Text
            End If

        End Set
    End Property

    Public Property IsPrintPage() As Boolean
        Get
            Return Me.CommentsReadOnlyLabel.Visible
        End Get

        Set(ByVal value As Boolean)
            Me.CommentsReadOnlyLabel.Visible = value
            Me.CommentsTextBox.Visible = Not value

            Me.NumberOfTasksLabel.Font.Bold = value
            Me.CommentsLabel.Font.Bold = value
            Me.LevelOfAssistanceLabel.Font.Bold = value

            Me.LevelOfAssistanceReadOnlyLabel.Visible = value
            Me.LevelOfAssistanceDropDownList.Visible = Not value

            If value Then
                Me.NumberOfRoomsTextBox.BackColor = Drawing.Color.Transparent
                Me.NumberOfRoomsTextBox.BorderStyle = BorderStyle.None
            End If

        End Set
    End Property

    ''' <summary>
    ''' Get or sets the number of rooms textbox text value.
    ''' </summary>	
    ''' <remarks></remarks>
    Public Property NumberOfRooms() As String
        Get
            Return Me.NumberOfRoomsTextBox.Text
        End Get
        Set(ByVal value As String)
            Me.NumberOfRoomsTextBox.Text = value
        End Set
    End Property

    ''' <summary>
    ''' Gets or sets the comments textbox text value.
    ''' </summary>	
    ''' <remarks></remarks>
    Public Property Comments() As String
        Get
            Return Me.CommentsTextBox.Text
        End Get
        Set(ByVal value As String)
            Me.CommentsTextBox.Text = value
            Me.CommentsReadOnlyLabel.Text = value
        End Set
    End Property

    ''' <summary>
    ''' Determines whether a template has been filled out.
    ''' </summary>	
    ''' <remarks></remarks>
    Public ReadOnly Property IsCompleted() As Boolean
        Get
            Return Me.LevelOfAssistanceDropDownList.SelectedItem.ToString = "Not Applicable" OrElse _
                   (Me.NumberOfRoomsTextBox.Text <> "" And _
                    Me.LevelOfAssistanceDropDownList.SelectedIndex <> 0)
        End Get
    End Property

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

        With Me.LevelOfAssistanceDropDownList
            .Attributes.Add("onchange", "javascript: CheckNotApplicable('" & Me.LevelOfAssistanceDropDownList.ClientID & "'); return true;")
            .DataSource = Cdm.RIDataCore.LookupTables.LuLevelOfAssistance.ListAll()
            .DataTextField = "Description"
            .DataValueField = "LevelOfAssistanceId"
            .DataBind()
            .Items.Insert(0, New ListItem("Select...", 0))
            .SelectedIndex = 0
        End With


    End Sub

    Public Sub DisableFields()

        For Each ctrl As Control In Me.Controls
            If TypeOf ctrl Is TextBox Then
                CType(ctrl, TextBox).Enabled = False
            ElseIf TypeOf ctrl Is DropDownList Then
                CType(ctrl, DropDownList).Enabled = False
            ElseIf TypeOf ctrl Is CheckBox Then
                CType(ctrl, CheckBox).Enabled = False
            End If
        Next


        Me.CommentsReadOnlyLabel.Visible = True
        Me.CommentsTextBox.Visible = False

    End Sub

End Class
